<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="shortcut icon" href="favicon.ico" />
    	<link href="../../css/bootstrap.min14ed.css" rel="stylesheet" /> 
    <link href="../../css/font-awesome.min93e3.css" rel="stylesheet" />
    <link href="../../css/animate.min.css" rel="stylesheet" />
    <link href="../../css/style.min862f.css" rel="stylesheet" />
    <!-- 表格 -->
    <!--<link rel="stylesheet" href="../../css/plugins/bootstrap-table/bootstrap-table.min.css" />-->
    <link rel="stylesheet" href="../../css/custom.css" />
</head>
<body>
	<div class="wrapper ">
		<!--搜索功能栏-->
		<div class="top-tool row">
			<div class="pull-right" style="padding-top: 4px;">
				<a href="javascript:location.reload()" class="btn btn-warning btn-sm"><i class="fa fa-refresh"></i> 刷新</a>
				<button type="button" class="btn btn-danger btn-sm sendAllMessage"><i class="fa fa-envelope" aria-hidden="true"></i> 消息</button>
				<a href="views/merchant/createMerchant.html" data-title="新增商家" data-name="a2"  class="btn btn-primary btn-sm createTab">新增商家</a>
			</div>
			<form action="" class="form-inline"  style="padding-top: 4px;">
				<div class="form-group">
					<label>名称:</label>
					<div class="input-group">
						<input type="text" name="" id="mech" class="form-control input-sm" />
						<div class="input-group-btn">
                            <button type="button" class="btn btn-white dropdown-toggle btn-sm" data-toggle="dropdown">
                                <span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                            </ul>
                        </div>
					</div>
				</div>
				<div class="form-group">
					<select name="" class="form-control input-sm">
						<option value="all">--全部--</option>
						<option value="1">个体户</option>
						
					</select>
					<select name="" class="form-control input-sm">
						<option value="all">--全部--</option>
						<option value="1">器材租赁</option>
					</select>
					<select name="" class="form-control input-sm">
						<option value="all">--全部--</option>
						<option value="all">未认证</option>
						<option value="all">已认证</option>
					</select>
				</div>
					
				<div class="form-group">
					<label>入驻时间:</label>
					<input placeholder="开始日期" class="form-control input-sm layer-date" id="start">
					 &nbsp;至&nbsp; 
                    <input placeholder="结束日期" class="form-control input-sm layer-date" id="end">
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">搜索</button>
					<button type="button" class="btn btn-warning btn-sm" onclick="location.href=location.origin + location.pathname">清空搜索</button>
				</div>
			</form>
		</div>
		<!--end-->
		
		<!--内容区域-->
		<div  class="animated fadeInRight content-body">
			<table class="table table-hover table-striped">
				<thead>
					<tr>
						<th><input type="checkbox" name="" class="allCheck"  /></th>
						<th>名称</th>
						<th>服类类型</th>
						<th>企业类型</th>
						<th>入驻时间</th>
						<th>认证</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<tr data-id="1">
						<td><input type="checkbox" name="" class="childCheck" /></td>
						<td>
							<img src="../../img/a1.jpg" width="50px" class="pull-left" />
							<div class="pull-left" style="padding-left: 10px;">
								<p>深圳市大同影视娱乐有限公司</p>
								<p>大同制作</p>
							</div>
						</td>
						<td>器材租赁,场地租赁,后期服务</td>
						<td>政府</td>
						<td>2015-01-01</td>
						<td><span class="label label-primary">已认证</span></td>
						<td>
							<button type="button" class="btn btn-danger disableMerchant">禁用</button>
							<button type="button" class="btn btn-success sendMessag">消息</button>
							<a type="button" class="btn btn-primary" href="lookup.html" >查看</a>
						</td>
					</tr>
					<tr data-id="2">
						<td><input type="checkbox" name="" class="childCheck" /></td>
						<td>
							<img src="../../img/a1.jpg" width="50px" class="pull-left" />
							<div class="pull-left" style="padding-left: 10px;">
								<p>深圳市大同影视娱乐有限公司</p>
								<p>大同制作</p>
							</div>
						</td>
						<td>器材租赁,场地租赁,后期服务</td>
						<td>政府</td>
						<td>2015-01-01</td>
						<td><span class="label label-danger">未认证</span></td>
						<td>
							<button type="button" class="btn btn-danger disableMerchant">禁用</button>
							<button type="button" class="btn btn-success sendMessag">消息</button>
							<a type="button" class="btn btn-primary" href="lookup.html" >查看</a>
						</td>
					</tr>
					<tr data-id="3">
						<td><input type="checkbox" name="" class="childCheck" /></td>
						<td>
							<img src="../../img/a1.jpg" width="50px" class="pull-left" />
							<div class="pull-left" style="padding-left: 10px;">
								<p>深圳市大同影视娱乐有限公司</p>
								<p>大同制作</p>
							</div>
						</td>
						<td>器材租赁,场地租赁,后期服务</td>
						<td>政府</td>
						<td>2015-01-01</td>
						<td><span class="label label-danger">未认证</span></td>
						<td>
							<!--data-toggle="modal" data-target="#myModal"-->
							<button type="button" class="btn btn-warning disableMerchant enabled">启用</button>
							<button type="button" class="btn btn-success sendMessag" >消息</button>
							<a type="button" class="btn btn-primary" href="lookup.html" >查看</a>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		<!--end-->
	</div>


<div class="modal inmodal" id="myModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content animated fadeInDown">
        		<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">关闭</span>
			    </button>
	        		<h4 class="modal-title">编辑消息</h4>
				<small class="font-bold ">正在给<span class="text-danger">xxx</span>发信息</small>
			</div>
			<div class="modal-body">
				<form action="" class="form-horizontal">
					<div class="form-group">
						<label>标题:</label>
						<input type="text" name="" class="form-control msgTitle"  />
					</div>
					<div class="form-group">
						<label>详情:</label>
						<textarea name="" class="form-control msgBody"></textarea>
					</div>
				</form>
				
			</div>
			<div class="modal-footer">
			    <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
			    <button type="button" class="btn btn-primary saveSend"  ><i class="fa fa-paper-plane-o" aria-hidden="true"></i> 发送</button>
			</div>
        </div>
    </div>

<script src="../../js/jquery.min.js"></script>
<script src="../../js/bootstrap.min.js"></script>
<script src="../../js/content.min.js"></script>
<!--搜索提示-->
<script src="../../js/plugins/suggest/bootstrap-suggest.min.js"></script>
<!--日期-->
<script src="../../js/plugins/layer/laydate/laydate.js"></script>
<!--自定义-->
<script src="../../js/config.js"></script>
<script>
	var testBsSuggest=$("#mech,#client").bsSuggest({
        url:"../../data.json",
        idField:"userId",
        keyField:"userName"
    })
    .on("onDataRequestSuccess",function(e,result){
    })
    .on("onSetSelectValue",function(e,keyword){
    })
    .on("onUnsetSelectValue",function(e){
    });
     laydate(start);
     laydate(end);
     
     
     //发消息  单个
     $('.sendMessag').click(function(){
//   	$('#myModal').modal('show');
		var mid = $(this).parents('tr').data('id');
		var name = $(this).parents('tr').find('td:eq(1) p:eq(1)').text();
		$('.saveSend').attr('data-mid', mid);
		$('.modal-header small span').text('[ '+name+' ]');
		$('#myModal').modal('show');
     });
     //发消息 多个
     $('.sendAllMessage').click(function(){
     	var arrId = [], arrName = [];
     	$('.childCheck').each(function(){
     		if( this.checked ){
     			arrId.push($(this).parents('tr').data('id'));
     			arrName.push($(this).parents('tr').find('td:eq(1) p:eq(1)').text());
     		}
     	});
     	if( arrId.length < 1 ){
     		parent.layer.alert("请勾选商家");
     		return ;
     	}
     	var name = '';
     	if( arrName.length > 2 ){
     		name = arrName[0] + ',' + arrName[1] + '...';
     	}else{
     		name = arrName.join(',');
     	}
     	$('.saveSend').attr('data-mid', arrId.join(','));
     	$('.modal-header small span').text('[ '+name+' ] 共'+arrName.length+'个商家');
     	$('#myModal').modal('show');
     });
     //模态关闭事件
     $('#myModal').on('hide.bs.modal', function(){
     	$('.saveSend').removeAttr('data-mid');
     });
     //确认发送事件
     $('.saveSend').click(function(){
     	var mid = $(this).data('mid');
     	var tls = $('.msgTitle').val(),content = $('.msgBody').val();
     	if( !$.trim(tls) || !$.trim( content ) ){
     		$.msg('标题或者详情没填写', 'error');
     		return ;
     	}
     	if( !mid ) return ;
     	//ajax
     	$('#myModal').modal('hide');
     });
     
     
     //禁用,启用
     $('.disableMerchant').click(function(){
     	var type = 1;
     	if( $(this).hasClass('enabled') ){
     		//禁用中
     		type = 1;
     	}else{
     		//启用中
     		type = 2;
     	}
     	var mid = $(this).parents('tr').data('id');
//   	$.ajax
		//成功后,根据type变成按钮状态
		type == 1? ($(this).removeClass('enabled btn-warning').text('禁用').addClass('btn-danger'))
				:($(this).addClass('enabled btn-warning').text('启用').removeClass('btn-danger'));
     	
     });
             
</script>
</body>
</html>
